/* eslint-disable no-unused-vars */
/* eslint-disable class-methods-use-this */
/* eslint-disable import/no-cycle */
import React from 'react';
import { Tabs, Form, Input } from 'antd';
import BaseControl from './BaseControl';
import BindSelect from '../common/BindSelect';

/**
 * 标签控件:允许输入一段文本
 */
class LabelControl extends BaseControl {
  static create(props, dataProps, extProps) {
    return new LabelControl(props, dataProps, extProps);
  }

  constructor(props, dataProps, extProps) {
    const dataProps2 = {
      title: '',
      type: 'Label',
      // height: 30,
      text: '编辑右侧属性栏,输入一段文本...',
      ...dataProps,
    };
    super(props, dataProps2, extProps);
    this.name = '标签';
    // this.icon = '';
  }

  getPropertyTabs(parentForm) {
    return [
      ...super.getPropertyTabs(parentForm),
      <Tabs.TabPane tab="控件配置" key="3">
        <Form.Item label="文本内容">
          <BindSelect
            data={this.data}
            field="text"
            defaultValue=""
            child={() => {
              return (
                <Input.TextArea
                  placeholder="文本内容"
                  value={this.data.text}
                  onChange={(event) => {
                    this.data.text = event.target.value;
                    parentForm.refreash();
                  }}
                  rows={8}
                />
              );
            }}
          />
        </Form.Item>
      </Tabs.TabPane>,
    ];
  }

  getDesignControl(parentForm) {
    return <p {...this.extProps}>{this.data.text}</p>;
  }
}

export default LabelControl;
